/**
 * 
 */
//package com.maoye;

import java.io.Console;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

/**
 * @author Administrator
 *
 */
public class TestDo21 {
	private static String SP_CODE = "21";
	private static String SP_CODE_TWO = "2";
	private static String SP_CODE_ONE = "1";
	
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		List<String> list = randomDatas(100);
		if(list != null){
			for(String s : list){
				System.out.println(s);
			}
		}
		
		print(list);
		long end = System.currentTimeMillis();
		System.out.println((end - start) + "ms");
	}
	
	private static void test(){
		List<String> list = new ArrayList<String>();
		String str = readConsoleStrThrowScanner("请输入数据行数：");
		int lineNum = 0;
		if(str != null && !"".equals(str.trim())){
			try{
			lineNum = Integer.parseInt(str);
			}catch(Exception e){
				e.printStackTrace();
				lineNum = 0;
			}
		}
		while(lineNum> 0){
			String s = readConsoleStrThrowScanner("");
			list.add(s);
			lineNum--;
		}
		
		System.out.println(list);
		print(list);
	}
	
	private static void print(List<String> list){
		if(list != null){
			for(String s : list){
				if(s.indexOf(SP_CODE) > -1){
					System.out.println(s + " ::: The streak is broken!");
				}else if(isTrue(s)){
					System.out.println(s + " ::: The streak is broken!");
				}
				else {
					//System.out.println(s + " ::: The streak lives still in our heart!");
				}
			}
		}
	}
	
	private static boolean isTrue(String str){
		boolean flag = false;
		if(str != null){
			int size = str.length();
			int spCodeTwoIndex =  str.indexOf(SP_CODE_TWO);
			int spCodeOneIndex =  str.lastIndexOf(SP_CODE_ONE);
			if(spCodeTwoIndex > -1 && spCodeTwoIndex < size && spCodeTwoIndex < spCodeOneIndex){
				flag = true;
			}
		}
		return flag;
	}
	
	private static List<String> randomDatas(int lineNum){
		List<String> list = new ArrayList<String>(100);
		Random random = new Random();
		for(int i = 0; i< lineNum;i++){
			int data = Math.abs(random.nextInt() % 1000001);
			list.add(data+"");		
			}
		return list;
	}
	
	private static String readConsoleStrThrowConsole(String prompt){
		Console console = System.console();
        if (console == null) {
            throw new IllegalStateException("Console is not available!");
        }
        return console.readLine(prompt);
	}
	
	private static String readConsoleStrThrowScanner(String prompt){
		Scanner scanner = new Scanner(System.in);
	    System.out.print(prompt);
	    return scanner.nextLine();
	}
	
	

}
